﻿@model WebAdmin.Models.Framework.FwMemGroup

@{
    ViewBag.Title = "网站管理平台_编辑群组";
}

@section HeadContent
{
    <script type="text/javascript">
        var onGrpSuccess = function (response, data) {
            Ext.Msg.show({ title: '提示', msg: data.extraParams.Msg, buttons: Ext.Msg.OK, icon: Ext.Msg.INFO, modal: true,
                fn: function (btn) {
                    var grid = window.parent.App.GridPanel1;
                    grid.getStore().reload();
                    var wnd = window.parent.App.Window1;
                    wnd.close();
                }
            });
        };

        var onGrpFailure = function (response, data) {
            Ext.Msg.show({ title: '提示', msg: data.extraParams.Msg, buttons: Ext.Msg.OK, icon: Ext.Msg.ERROR, modal: true });
        };
    </script>
}

@(Html.X().Viewport()
    .Layout("fit")
    .Items(
        Html.X().FormPanel()
            .ID("FormPanel1")
            .Layout("fit")
            .Items(
                Html.X().Panel()
                    .Border(false)
                    .Padding(5)
                    .Layout("form")
                    .Defaults(
                        Html.X().Parameter().Name("AnchorHorizontal").Value("90%")
                    )
                    .Items(
                        Html.X().TextFieldFor(m => m.GroupName).ID("GroupName").FieldLabel("群组名称").AllowBlank(false).MaxLength(30),
                        Html.X().ComboBoxFor(m => m.GroupType).ID("GroupType").FieldLabel("群组类型").AllowBlank(false).Editable(false)
                            .Items(
                                Html.X().ListItem().Text("一般群组").Value("1"),
                                Html.X().ListItem().Text("系统群组").Value("2")
                            ).SelectedItems(Model.GroupType.ToString())
                    )
            )
            .TopBar(
                Html.X().Toolbar().Items(
                    Html.X().Button().Text("保存").Icon(Icon.Disk)
                        .DirectEvents(de =>
                        {
                            de.Click.Action = "EditMemGroup";
                            de.Click.EventMask.ShowMask = true;
                            de.Click.EventMask.Msg = "正在保存";
                            de.Click.Success = "onGrpSuccess";
                            de.Click.Failure = "onGrpFailure";
                        })
                        .Listeners(ls =>
                        {
                            ls.Click.Handler = "if (!App.FormPanel1.getForm().isValid()) { Ext.Msg.show({title: '提示', icon: Ext.MessageBox.ERROR, msg: '表单信息未填写完整，请检查后再次提交！', buttons:Ext.Msg.OK}); return false; }";
                        })
                )
            )
            .BottomBar(Html.X().StatusBar().DefaultText("Ready"))
                .Listeners(ls => ls.ValidityChange.Handler = "this.dockedItems.get(1).setStatus({text : valid ? '表单信息填写正确！' : '表单信息未填写完整，请检查后再次提交！', iconCls: valid ? 'icon-accept' : 'icon-exclamation'});")
    )
)